package cn.lizemin.fakedata.common;

import lombok.Getter;

/**
 * @author 李泽民
 * @Date 2024/1/18 19:47
 * @Description
 */
@Getter
public class RespBean {

    private final Integer code;

    private String message;

    private Object data;

    private RespBean(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static RespBean success() {
        return new RespBean(200, "成功", null);
    }

    public static RespBean success(ResultEnum resultEnum) {
        return new RespBean(resultEnum.getCode(), resultEnum.getMessage(), null);
    }

    public static RespBean success(Object data) {
        return new RespBean(200, "成功", data);
    }

    public static RespBean fail() {
        return new RespBean(500, "失败", null);
    }

    public static RespBean fail(ResultEnum resultEnum) {
        return new RespBean(resultEnum.getCode(), resultEnum.getMessage(), null);
    }

    public static RespBean fail(Integer code, String message) {
        return new RespBean(code, message, null);
    }

    public RespBean message(String message) {
        this.message = message;
        return this;
    }

    public RespBean data(Object data) {
        this.data = data;
        return this;
    }


}
